package com.jeesite.modules.kj.file.model;

import com.jeesite.modules.file.entity.FileUpload;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import org.springframework.beans.factory.annotation.Value;

@ApiModel(value="文件")
public class FileModel {
    @ApiModelProperty(value="id", required=true)
    private String id;
    @ApiModelProperty(value="文件名")
    private String name;
    @ApiModelProperty(value="文件地址")
    private String path;
    @ApiModelProperty(value="文件尺寸，仅图片")
    private String meta;
    @ApiModelProperty(value="文件类型")
    private String type;
    @ApiModelProperty(value="文件大小(b)")
    private long size;

    @Value("${file.url}")
    private String url;

    public FileModel() {
    }
    public FileModel(FileUpload fileUpload, String url)
    {
        this.setId(fileUpload.getId());
        this.setName(fileUpload.getFileName());
        this.setMeta(fileUpload.getFileEntity().getFileMeta());
        this.setSize(fileUpload.getFileEntity().getFileSize());
        this.setPath(url + fileUpload.getFileEntity().getFilePath() + fileUpload.getFileEntity().getId() + "." + fileUpload.getFileEntity().getFileExtension());
        this.setType(fileUpload.getFileType());
    }

    public String getId() {
        return id;
    }

    public void setId(String id) {
        this.id = id;
    }

    public String getName() {
        return name;
    }

    public void setName(String name) {
        this.name = name;
    }

    public String getPath() {
        return path;
    }

    public void setPath(String path) {
        this.path = path;
    }

    public String getMeta() {
        return meta;
    }

    public void setMeta(String meta) {
        this.meta = meta;
    }

    public String getType() {
        return type;
    }

    public void setType(String type) {
        this.type = type;
    }

    public long getSize() {
        return size;
    }

    public void setSize(long size) {
        this.size = size;
    }
}
